// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "src/loadcontainer.h"
#if (TARGET_OS == OS_POSIX)

#if (OS_COMPILER == CC_GCC)
void __attribute__((used)) so_section_init(void)
{
    asm(".section .init");
    asm(".section .text");
}
void __attribute__((used)) so_section_fini(void)
{
    asm(".section .fini");
    asm(".section .text");
}
#endif

#elif (TARGET_OS == OS_WIN)

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call) {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

#endif

_stdmethod_export(HRESULT, DoInit)()
{
    CLoadContainer loader("{409C8B8C-8467-47EE-B1BE-4E4112E64926}");
    LPSTRING path = _T("/home/com/Snows/libs/");

    LPCSTR code = "{\"component\": [ 	\
		\"{F170A724-AACA-4603-BB1C-0A8EAF1C3322}:asynio:1:20\",	\
		\"{ED660EF7-7D0B-4CBE-8D92-D5F225434464}:http:2:20\",	\
		\"{99148517-E9AB-4F72-A2E3-012625A35E95}:net:3:20\",	\
		\"{201409F6-22F8-48d3-A69F-7935BDDE6BFF}:msgbus:4:20\"]}";

    loader.Init(path, code);
    loader.Start(0);
    loader.Stop(0, 0);
    loader.UnInit();

    return S_OK;
}
